#ifndef CHATWINDOW_H
#define CHATWINDOW_H

#include <QMainWindow>
#include <QTextEdit>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include "chatclient.h"
// 移除了对messagestore.h的包含

QT_BEGIN_NAMESPACE
namespace Ui { class ChatWindow; }
QT_END_NAMESPACE

class ChatWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    ChatWindow(const QString &username, QWidget *parent = nullptr);
    ~ChatWindow();
    
private slots:
    void onSendClicked();
    void onClearClicked();
    void onSaveClicked();
    void onConnected();
    void onDisconnected();
    void onErrorOccurred(const QString &error);
    void onMessageReceived(const Message &message);
    void onReturnPressed();
    
private:
    Ui::ChatWindow *ui;
    
    // UI组件
    QTextEdit *m_chatDisplay;
    QLineEdit *m_messageInput;
    QPushButton *m_sendBtn;
    QPushButton *m_clearBtn;
    QPushButton *m_saveBtn;
    QLabel *m_statusLabel;
    QLabel *m_usernameLabel;
    
    // 功能组件
    ChatClient *m_client;
    // 移除了MessageStore *m_messageStore;
    QString m_username;
    
    void setupUI();
    // 移除了loadHistoryMessages()声明
    void updateStatus(const QString &status, bool error = false);
    void appendMessage(const Message &message, bool isSelf = false);
    void appendSystemMessage(const Message &message);  // 添加系统消息显示方法声明
};

#endif // CHATWINDOW_H